package com.ricky.controller;

import com.ricky.entity.Customer;
import com.ricky.entity.User;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * rest风格
 */
@RestController
@RequestMapping(value="/users")
public class MyRestController {

    @RequestMapping(value="/{user}", method= RequestMethod.GET)
    public User getUser(@PathVariable Long user) {
        // ...
        return new User();
    }

    /**
     * getUser 等价于这个
     * @param user
     * @return
     */
    @GetMapping(value="/{user2}")
    public User getUser2(@PathVariable Long user) {
        // ...
        return new User();
    }

    @RequestMapping(value="/{user}/customers", method=RequestMethod.GET)
    List<Customer> getUserCustomers(@PathVariable Long user) {
        List<Customer> customers=new ArrayList<Customer>();
        // ...
        return customers;
    }

    @RequestMapping(value="/{user}", method=RequestMethod.DELETE)
    public User deleteUser(@PathVariable Long user) {
        // ...
        return new User();
    }

}